﻿using Microsoft.EntityFrameworkCore;
using Sigma.Admin.API.Context.Entity;
using Sigma.Admin.API.Context.UnitOfWork;
using Sigma.Admin.API.Context;
using Newtonsoft.Json;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore.Query;

namespace Sigma.Admin.API.Context.Repository
{
    public class UserRepository : Repository<UserEntity>, IRepository<UserEntity>
    {
        public UserRepository(EFDbContext dbContext) : base(dbContext)
        {

        }

        public Task< List<int>> GetUserP_Keys(int id)
        {
           var pKeys= GetFirstOrDefault(selector:y=>y.PermissionKey,predicate:x=>x.Id == id);
            var res = JsonConvert.DeserializeObject<List<int>>(pKeys);
            return Task.FromResult(res??new List<int>());
        }

       
    }
}
